﻿//用来增加编辑区域到最后一行
function placeTextArea(obj,action) {
    try {
        if (document.getElementById("submitForm") != null) {
            return;//实例已经存在，不能再创建一个.
        }
        var parent = document.createElement("form");
        var textArea = document.createElement("textarea");
        textArea.setAttribute("cols", "30");
        textArea.setAttribute("rows", "50");
        textArea.setAttribute("id", "content");
        textArea.setAttribute("name","content");
        var textContent = document.getElementById("textContent");
        textArea.value = textContent.innerHTML;
        parent.appendChild(textArea);
        parent.setAttribute("action", action);
        parent.setAttribute("id", "submitForm");
        parent.setAttribute("name","submitForm");
        obj = obj.parentNode;
        obj.appendChild(parent);

        CKEDITOR.replace("content", {
            skin: "kama",height:"500px"
        });
    } catch (e) {
    alert(e);
    }
}
//关闭编辑
function closeTextArea(obj) {
    try {
        var child1 = document.getElementById("submitForm");
        var child2 = document.getElementById("content");
        if (child1 != null) {
            child1.removeChild(child2);
            obj = obj.parentNode;
            obj.revmoveChild(child1);
        }
    } catch (e) {
    alert(e);
    }
}
//提交编辑
function submit() {
    try {
        var parent = document.getElementById("submitForm");
        if (parent != null) {
            parent.submit();
        }
    } catch (e) {
    alert(e);
    }
}
